<#import "../macro/components.ftl" as components/>
<#include "../macro/layout_default.ftl"/>

<@head>
<link rel="stylesheet" href="/misc/app/css/product_list.css"/>
</@head>

<@body>
<script src="/misc/app/js/logistics_list.js"></script>
</@body>

<@layout_default>
<div class="box">
    <div class="box-header with-border">
        <span class="pull-right text-muted">共 ${logisticsList.resultTotal} 条记录</span>
        <form class="form-inline" action="/logisticscompany">
            <div class="input-group">
                <div class="input-group-addon">关键字</div>
                <input type="text" class="form-control" style="width: 260px" name="name" value="${name!}" placeholder="承运方名称"/>
            </div>
            <button type="submit" class="btn btn-warning"><i class="fa fa-search"></i> 查询</button>
            <button type="button" id="search_reset" class="btn btn-warning"><i class="fa"></i> 重置</button>
            <button type="button" class="btn btn-default" name="btn_new_product" data-toggle="modal" data-target="#md_new_product"><i class="fa fa-plus"></i> 录入承运方</button>
        </form>
        <form class="form-inline hide">
            <input class="form-control"/>
            <input type="email" class="form-control"/>
            <button type="submit" class="btn btn-default">Send invitation</button>
        </form>
    </div>

    <!-- /.box-header -->
    <div class="box-body">
        <table class="table table-striped table-hover">
            <tr>
                <th>ID</th>
                <th>承运方</th>
                <th>官网</th>
                <th>创建时间</th>
                <th>操作人</th>
                <th>操作</th>
            </tr>
            <#list logisticsList.result as item>
                <tr>
                    <td>${item.id}</td>
                    <td>${item.name}</td>
                    <td>${item.website!}</td>
                    <td>${item.cTime?string("yyyy-MM-dd hh:mm:ss")}</td>
                    <td>${item.cAdmin}</td>
                    <td>
                        <button type="button" class="btn btn-default btn-xs" data-toggle="modal" data-target="#md_edit_product" data-logistics-name="${item.name}" data-logistics-id="${item.id?c}">编辑</button>
                        <button type="button" class="btn btn-default btn-xs" name="btn_delete_product" data-logistics-id="${item.id}">删除</button>
                    </td>
                </tr>
            </#list>
        </table>
    </div>
    <!-- /.box-body -->
    <div class="box-footer text-center">
        <@components.pagination "/logisticscompany?name=${name!}&page=$page",logisticsList.page,logisticsList.pageTotal/>
    </div>
</div>


<!--=========== Modals =============-->
<!-- md_new_product -->
<div class="modal" id="md_new_product" tabindex="-1">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title"><i class="fa fa-plus"></i> 录入承运方</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" name="form_new_product">
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 承运方</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" placeholder="承运方" name="name" maxlength="100" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 官网</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" placeholder="官网" name="website" maxlength="200" />
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" name="btn_save_new_product">保存</button>
            </div>
        </div>
    </div>
</div>
<!-- md_new_product -->
<div class="modal" id="md_edit_product" tabindex="-1">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title"><i class="fa fa-pencil-square-o"></i> 编辑承运方</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" name="form_edit_product">
                    <input type="hidden" name="id"/>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong>承运方</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" name="name" maxlength="100" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong>官网</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" name="website" maxlength="200" />
                        </div>
                    </div>
                    
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" name="btn_save_edit_product">保存</button>
            </div>
        </div>
    </div>
</div>

</@layout_default>